<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登陆</title>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=10"/>
    <meta name="author" content="CMtime"/>
    <meta name="version" content="1.0"/>

    <link rel="stylesheet" href="<?php echo SITE;?>static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="<?php echo SITE;?>css/login.css" media="all">
    <link rel="stylesheet" href="<?php echo SITE;?>css/style.css" media="all">
    <style>
        /* 覆盖原框架样式 */
        .layui-elem-quote{background-color: inherit!important;}
        .layui-input, .layui-select, .layui-textarea{background-color: inherit; padding-left: 30px;}
    </style>
</head>
<body>
<div class="zyl_lofo_main">
    <fieldset class="layui-elem-field layui-field-title zyl_mar_02">
        <legend>欢迎登陆 - 管理平台</legend>
    </fieldset>
    <div class="layui-row layui-col-space15">
        <form class="layui-form zyl_pad_01" action="">
            <div class="layui-col-sm12 layui-col-md12">
                <div class="layui-form-item">
                    <input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="账号" class="layui-input">
                    <i class="layui-icon layui-icon-username zyl_lofo_icon"></i>
                </div>
            </div>
            <div class="layui-col-sm12 layui-col-md12">
                <div class="layui-form-item">
                    <input type="password" name="password" lay-verify="required" autocomplete="off" placeholder="密码" class="layui-input">
                    <i class="layui-icon layui-icon-password zyl_lofo_icon"></i>
                </div>
            </div>
            <div class="layui-col-sm12 layui-col-md12">
                <div class="layui-row">
                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
                        <div class="layui-form-item">
                            <input type="text" name="captcha" id="captcha" lay-verify="required" autocomplete="off" placeholder="验证码" class="layui-input" maxlength="4">
                            <i class="layui-icon layui-icon-vercode zyl_lofo_icon"></i>
                        </div>
                    </div>
                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
                        <div class="zyl_lofo_vercode zylVerCode">
                            <img src="{:captcha_src()}" alt="captcha" style="height: 38px;width: 100px;cursor:pointer;" id="captcha_img" onclick="this.src=this.src+'?'+Math.random()"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-sm12 layui-col-md12">
                <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="login">立即登录</button>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript" src="<?php echo SITE;?>static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '<?php echo SITE;?>static/layuiadmin/'
    }).extend({
        index: 'lib/index'
    }).use(['form'], function(){
        let form = layui.form
            ,$ = layui.jquery
            ,layer = layui.layer;

        //监听提交
        form.on('submit(login)', function(data){
            $.ajax({
                type: 'POST',
                url: "{:url('login/check')}",
                data: data.field,
                datatype: 'json',
                success: function (res) {
                    layer.msg(res.msg);
                    if(res.status){
                        setTimeout(
                            function () {
                                let url = '{$url}';
                                if(!url){
                                    url = '/';
                                }
                                self.location = url;
                            },1500
                        );
                    }else{
                        $('#captcha_img').click();
                    }
                }
            });
            return false;
        });

    });
</script>
</body>
</html>